#include <graphics.h>
#include <conio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <ctime>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")

// 基础游戏对象类
class GameObject {
public:
    virtual ~GameObject() {}
    virtual int getX() const = 0;
    virtual int getY() const = 0;
    virtual int getWidth() const = 0;
    virtual int getHeight() const = 0;
    virtual void draw() = 0;
};

// 游戏背景类
class GameBackground {
private:
    int speed = 8;  // 滚动速度
    int groundY;    // 地面Y坐标
    int groundLine; // 地面线的位置
    int screenWidth, screenHeight;
    
    // 地面点的位置
    struct GroundDot {
        int x, y;
        GroundDot(int posX, int posY) : x(posX), y(posY) {}
    };
    
    std::vector<GroundDot> dots; // 地面上的装饰点

public:
    GameBackground(int width, int height) {
        screenWidth = width;
        screenHeight = height;
        
        // 设置地面线的位置（屏幕底部上方一点）
        groundY = screenHeight - 30;
        groundLine = groundY;
        
        // 初始化地面上的随机点（作为装饰）
        initGroundDots();
    }
    
    // 初始化地面上的点
    void initGroundDots() {
        // 清空旧的点
        dots.clear();
        
        // 在地面线上随机生成一些点作为装饰
        std::random_device rd;
        std::mt19937 gen(rd());
        std::uniform_int_distribution<> dotCount(30, 50); // 点的数量
        std::uniform_int_distribution<> dotX(0, screenWidth);
        std::uniform_int_distribution<> dotYOffset(0, 5);
        
        int count = dotCount(gen);
        for (int i = 0; i < count; i++) {
            int x = dotX(gen);
            int y = groundY - dotYOffset(gen);
            dots.push_back(GroundDot(x, y));
        }
    }
    
    void update() {
        // 更新地面点的位置
        for (auto& dot : dots) {
            dot.x -= speed;
            
            // 如果点移出屏幕左侧，将其移到右侧重新进入
            if (dot.x < 0) {
                dot.x = screenWidth;
            }
        }
    }
    
    void draw() {
        // 绘制纯白色背景
        setfillcolor(WHITE);
        solidrectangle(0, 0, screenWidth, screenHeight);
        
        // 绘制地面线
        setlinecolor(RGB(83, 83, 83)); // 浅灰色
        line(0, groundLine, screenWidth, groundLine);
        
        // 绘制地面上的点
        for (const auto& dot : dots) {
            // 使用小圆点作为地面装饰
            putpixel(dot.x, dot.y, RGB(180, 180, 180)); // 更浅的灰色
        }
    }
    
    int getGroundY() const {
        return groundY;
    }
};

// 云朵类
class Cloud : public GameObject {
private:
    IMAGE image;
    int speed = 1;
    int x, y;
    int width, height;

public:
    Cloud(int startX, int startY, const IMAGE& img) {
        x = startX;
        y = startY;
        image = img;
        width = image.getwidth();
        height = image.getheight();
    }
    
    void move() {
        x -= speed;
    }
    
    void draw() override {
        putimage(x, y, &image);
    }
    
    int getX() const override { return x; }
    int getY() const override { return y; }
    int getWidth() const override { return width; }
    int getHeight() const override { return height; }
};

// 仙人掌类
class Cactus : public GameObject {
private:
    IMAGE image;
    int speed = 8;
    int x, y;
    int width, height;
    const int MAX_HEIGHT = 65;  // 最大高度提高到65像素（原为60）

public:
    Cactus(int startX, int startY, const IMAGE& img) {
        x = startX;
        
        // 获取原始图像尺寸
        int origWidth = img.getwidth();
        int origHeight = img.getheight();
        
        // 计算缩放比例，保持宽高比
        double scale = 1.0;
        if (origHeight > MAX_HEIGHT) {
            scale = static_cast<double>(MAX_HEIGHT) / origHeight;
            width = static_cast<int>(origWidth * scale);
            height = MAX_HEIGHT;
        } else {
            width = origWidth;
            height = origHeight;
        }
        
        image = img;
        y = startY + (origHeight - height) - 5;  // 调整Y坐标，使底部对齐，再向上提高5像素
    }
    
    void move() {
        x -= speed;
    }
    
    void draw() override {
        putimage(x, y, &image);
    }
    
    int getX() const override { return x; }
    int getY() const override { return y; }
    int getWidth() const override { return width; }
    int getHeight() const override { return height; }
};

// 鸟类
class Bird : public GameObject {
private:
    std::vector<IMAGE> images;
    int speed = 10;
    int x, y;
    int width, height;
    int index = 0;
    int animCounter = 1;

public:
    Bird(int startX, int startY, const std::vector<IMAGE>& imgs) {
        x = startX;
        y = startY;
        images = imgs;
        width = images[0].getwidth();
        height = images[0].getheight();
    }
    
    void move() {
        x -= speed;
    }
    
    void draw() override {
        if (animCounter <= 8) {
            index = 0;
        } else {
            index = 1;
        }
        
        if (animCounter == 16) {
            animCounter = 0;
        }
        
        putimage(x, y, &(images[index]));
        animCounter++;
    }
    
    int getX() const override { return x; }
    int getY() const override { return y; }
    int getWidth() const override { return width; }
    int getHeight() const override { return height; }
};

// 翼龙类 - 使用鸟的图片资源作为替代
class Pterosaur : public GameObject {
private:
    std::vector<IMAGE> images;
    int speed = 12;  // 比鸟类更快
    int x, y;
    int width, height;
    int index = 0;
    int animCounter = 1;

public:
    Pterosaur(int startX, int startY, const std::vector<IMAGE>& imgs) {
        x = startX;
        y = startY;
        images = imgs;
        width = images[0].getwidth();
        height = images[0].getheight();
    }
    
    void move() {
        x -= speed;
    }
    
    void draw() override {
        if (animCounter <= 5) {
            index = 0;
        } else {
            index = 1;
        }
        
        if (animCounter == 10) {
            animCounter = 0;
        }
        
        putimage(x, y, &(images[index]));
        animCounter++;
    }
    
    int getX() const override { return x; }
    int getY() const override { return y; }
    int getWidth() const override { return width; }
    int getHeight() const override { return height; }
};

// 恐龙类
class Dragon : public GameObject {
private:
    std::vector<IMAGE> images;
    int x, y;
    int originalY;  // 记录原始Y坐标，用于跳跃后恢复
    int width, height;
    int index = 0;
    int animCounter = 1;
    int style = 0;  // 0：站立，1：蹲下
    int jump = 0;   // 0: 未起跳，1：开始上升，2：开始下降
    int jumpYAdd = 0;

public:
    bool isHit = false;

    Dragon(int startX, int startY, const std::vector<IMAGE>& imgs) {
        x = startX;
        y = startY;
        originalY = startY;
        images = imgs;
        width = images[0].getwidth();
        height = images[0].getheight();
    }
    
    void setJump() {
        if (style == 0 && jump == 0) {
            jump = 1;
            PlaySound(_T("sounds/dragon/jump.wav"), NULL, SND_ASYNC);
        }
    }
    
    void update() {
        if (jump == 1) {
            y -= 10;
            jumpYAdd += 10;
            if (jumpYAdd == 200) {
                jump = 2;
            }
        }
        
        if (jump == 2) {
            y += 10;
            jumpYAdd -= 10;
            if (jumpYAdd == 0) {
                jump = 0;
            }
        }
    }
    
    void draw() override {
        if (animCounter <= 5) {
            if (style == 0) {
                index = 0;
            } else {
                index = 2;
            }
        } else {
            if (style == 0) {
                index = 1;
            } else {
                index = 3;
            }
        }
        
        if (animCounter == 10) {
            animCounter = 0;
        }
        
        width = images[index].getwidth();
        height = images[index].getheight();
        putimage(x, y, &(images[index]));
        animCounter++;
    }
    
    void setStandingPosition() {
        if (style == 1) {
            style = 0;
            y -= 34;
        }
    }
    
    void setCrouchingPosition() {
        if (style == 0 && jump == 0) {
            style = 1;
            y += 34;
        }
    }
    
    int getX() const override { return x; }
    int getY() const override { return y; }
    int getWidth() const override { return width; }
    int getHeight() const override { return height; }
    int getStyle() const { return style; }  // 获取当前姿势
};

// 游戏主类
class Game {
private:
    const int screenWidth = 800;
    const int screenHeight = 350;
    bool running = true;
    
    GameBackground* background;
    
    std::vector<Cloud*> clouds;
    IMAGE cloudImage;
    
    std::vector<Cactus*> items;
    std::vector<IMAGE> itemImages;
    int itemSpawnCounter = 1;
    int itemSpawnInterval = 100;
    
    std::vector<Bird*> birds;
    std::vector<IMAGE> birdImages;
    int birdSpawnCounter = 1;
    int birdSpawnInterval = 150;
    
    std::vector<Pterosaur*> pterosaurs;
    // 翼龙将共用鸟的图片资源，不再单独加载
    int pterosaurSpawnCounter = 1;
    int pterosaurSpawnInterval = 180;
    
    Dragon* dragon;
    std::vector<IMAGE> dragonImages;
    
    IMAGE gameoverImage;
    IMAGE restartImage;
    int restartX, restartY;
    
    float score = 0.0f;
    
    // 初始化随机数生成器
    std::mt19937 rng;

    // 处理图像，使黑色背景透明(仅修改图像, 不改变绘制方式)
    void processImage(IMAGE* img) {
        // 获取图像数据
        DWORD* buffer = GetImageBuffer(img);
        int width = img->getwidth();
        int height = img->getheight();
        int size = width * height;
        
        // 将非常接近黑色的像素调整为白色
        // 这样在使用普通的putimage时会使黑色区域与白色背景融合
        for (int i = 0; i < size; i++) {
            COLORREF& color = buffer[i];
            BYTE r = GetRValue(color);
            BYTE g = GetGValue(color);
            BYTE b = GetBValue(color);
            
            // 将黑色或接近黑色的像素设为白色
            if (r < 10 && g < 10 && b < 10) {
                color = WHITE;
            }
        }
    }

public:
    Game() {
        try {
            // 初始化随机数生成器
            rng.seed(static_cast<unsigned int>(time(0)));
            
            // 初始化图形环境
            initgraph(screenWidth, screenHeight);
            setbkcolor(WHITE);
            cleardevice();
            
            // 创建背景
            background = new GameBackground(screenWidth, screenHeight);
            
            // 加载云图片
            loadimage(&cloudImage, _T("images/dragon/cloud.png"));
            processImage(&cloudImage);
            
            // 创建初始云朵
            createCloud();
            
            // 加载仙人掌图片
            for (int i = 0; i < 7; i++) {
                IMAGE img;
                TCHAR path[50];
                _stprintf_s(path, _T("images/dragon/item_%d.png"), i + 1);
                loadimage(&img, path);
                processImage(&img);
                itemImages.push_back(img);
            }
            
            // 加载鸟图片
            IMAGE birdImg1, birdImg2;
            loadimage(&birdImg1, _T("images/dragon/bird_1.png"));
            loadimage(&birdImg2, _T("images/dragon/bird_2.png"));
            processImage(&birdImg1);
            processImage(&birdImg2);
            birdImages.push_back(birdImg1);
            birdImages.push_back(birdImg2);
            
            // 加载恐龙图片
            for (int i = 0; i < 4; i++) {
                IMAGE img;
                TCHAR path[50];
                _stprintf_s(path, _T("images/dragon/dragon_%d.png"), i + 1);
                loadimage(&img, path);
                processImage(&img);
                dragonImages.push_back(img);
            }
            
            // 创建恐龙，根据背景地面高度调整恐龙位置
            int dragonX = 50;
            int dragonY = background->getGroundY() - dragonImages[0].getheight();
            dragon = new Dragon(dragonX, dragonY, dragonImages);
            
            // 加载游戏结束和重启图片
            loadimage(&gameoverImage, _T("images/dragon/gameover.png"));
            loadimage(&restartImage, _T("images/dragon/restart.png"));
            processImage(&gameoverImage);
            processImage(&restartImage);
        }
        catch (...) {
           

        }
    }
    
    ~Game() {
        // 释放资源
        delete background;
        delete dragon;
        
        // 清空所有容器并释放内存
        for (auto& cloud : clouds) {
            delete cloud;
        }
        clouds.clear();
        
        for (auto& item : items) {
            delete item;
        }
        items.clear();
        
        for (auto& bird : birds) {
            delete bird;
        }
        birds.clear();
        
        for (auto& pterosaur : pterosaurs) {
            delete pterosaur;
        }
        pterosaurs.clear();
        
        // 关闭图形环境
        closegraph();
    }
    
    void createCloud() {
        clouds.push_back(new Cloud(350, 30, cloudImage));
        clouds.push_back(new Cloud(650, 100, cloudImage));
    }
    
    void run() {
        BeginBatchDraw();
        
        while (running) {
            // 处理用户输入
            handleInput();
            
            // 更新游戏状态
            update();
            
            // 渲染游戏画面
            render();
            
            // 碰撞检测
            detectCollision();
            
            // 刷新屏幕
            FlushBatchDraw();
            
            // 控制帧率
            Sleep(16);  // 大约60fps
        }
        
        EndBatchDraw();
    }
    
    void handleInput() {
        // 处理鼠标点击事件
        if (MouseHit()) {
            MOUSEMSG msg = GetMouseMsg();
            if (msg.uMsg == WM_LBUTTONDOWN && dragon->isHit) {
                int x = msg.x;
                int y = msg.y;
                
                // 检查是否点击了重启按钮
                if (x >= restartX && x <= restartX + restartImage.getwidth() &&
                    y >= restartY && y <= restartY + restartImage.getheight()) {
                    // 重启游戏
                    restartGame();
                }
            }
            // 添加鼠标点击跳跃功能
            else if (msg.uMsg == WM_LBUTTONDOWN && !dragon->isHit) {
                dragon->setJump();
            }
        }
        
        // 处理键盘输入
        if (_kbhit()) {
            int key = _getch();
            
            // 如果按下ESC键
            if (key == 27) {
                running = false;
            }
            
            // 设置多个跳跃键
            if (key == 32 || // 空格键
                key == 'w' || key == 'W' || // W键
                key == 13 || // 回车键
                key == 72) { // 上箭头键(方向键的扫描码)
                dragon->setJump();
            }
        }
        
        // 检测方向键状态
        if (GetAsyncKeyState(VK_UP) & 0x8000) { // 添加上箭头键跳跃
            dragon->setJump();
        }
        
        if (GetAsyncKeyState(VK_DOWN) & 0x8000) {
            dragon->setCrouchingPosition();
        } else {
            dragon->setStandingPosition();
        }
    }
    
    void restartGame() {
        // 重置游戏状态
        dragon->isHit = false;
        score = 0.0f;
        
        // 清空所有障碍物
        for (auto& item : items) {
            delete item;
        }
        items.clear();
        
        for (auto& bird : birds) {
            delete bird;
        }
        birds.clear();
        
        for (auto& pterosaur : pterosaurs) {
            delete pterosaur;
        }
        pterosaurs.clear();
        
        // 重置计数器
        itemSpawnCounter = 1;
        birdSpawnCounter = 1;
        pterosaurSpawnCounter = 1;
    }
    
    void update() {
        if (dragon->isHit) {
            return;
        }
        
        // 更新背景
        background->update();
        
        // 更新云
        std::vector<Cloud*>::iterator cloudIt;
        for (cloudIt = clouds.begin(); cloudIt != clouds.end();) {
            (*cloudIt)->move();
            
            if ((*cloudIt)->getX() < -(*cloudIt)->getWidth()) {
                delete *cloudIt;
                cloudIt = clouds.erase(cloudIt);
            } else {
                ++cloudIt;
            }
        }
        
        // 检查是否需要创建新云朵
        if (clouds.empty() || clouds.back()->getX() < screenWidth - 300) {
            int randomY = rand() % 100 + 10;  // 随机高度
            clouds.push_back(new Cloud(screenWidth, randomY, cloudImage));
        }
        
        // 根据游戏难度（分数）调整障碍物生成概率
        int currentScore = static_cast<int>(score);
        
        // 仙人掌生成概率随分数增加而减少（当翼龙开始出现时）
        float cactusSpawnProbability = 1.0f;
        if (currentScore > 200) {
            cactusSpawnProbability = 0.7f;  // 减少30%的生成概率
        }
        
        // 更新仙人掌
        if (itemSpawnCounter % itemSpawnInterval == 0) {
            // 使用概率控制仙人掌生成
            std::uniform_real_distribution<float> probDist(0.0f, 1.0f);
            if (probDist(rng) < cactusSpawnProbability) {
                std::uniform_int_distribution<int> dist(0, static_cast<int>(itemImages.size()) - 1);
                int randomIndex = dist(rng);
                
                int x = screenWidth;
                int y = background->getGroundY() - itemImages[randomIndex].getheight(); // 使用地面高度
                
                items.push_back(new Cactus(x, y, itemImages[randomIndex]));
            }
        }
        itemSpawnCounter++;
        
        if (itemSpawnCounter >= itemSpawnInterval) {
            itemSpawnCounter = 0;
            std::uniform_int_distribution<int> dist(60, 110);
            itemSpawnInterval = dist(rng);
        }
        
        std::vector<Cactus*>::iterator itemIt;
        for (itemIt = items.begin(); itemIt != items.end();) {
            (*itemIt)->move();
            
            if ((*itemIt)->getX() < -(*itemIt)->getWidth()) {
                delete *itemIt;
                itemIt = items.erase(itemIt);
            } else {
                ++itemIt;
            }
        }
        
        // 更新鸟（当分数超过100时）
        if (currentScore > 100) {
            if (birdSpawnCounter % birdSpawnInterval == 0) {
                int x = screenWidth;
                int y = 210;  // 固定高度
                
                birds.push_back(new Bird(x, y, birdImages));
            }
            birdSpawnCounter++;
            
            if (birdSpawnCounter >= birdSpawnInterval) {
                birdSpawnCounter = 0;
                std::uniform_int_distribution<int> dist(150, 300);
                birdSpawnInterval = dist(rng);
            }
            
            std::vector<Bird*>::iterator birdIt;
            for (birdIt = birds.begin(); birdIt != birds.end();) {
                (*birdIt)->move();
                
                if ((*birdIt)->getX() < -(*birdIt)->getWidth()) {
                    delete *birdIt;
                    birdIt = birds.erase(birdIt);
                } else {
                    ++birdIt;
                }
            }
        }
        
        // 更新翼龙（当分数超过200时）
        if (currentScore > 200) {
            if (pterosaurSpawnCounter % pterosaurSpawnInterval == 0) {
                int x = screenWidth;
                int y = 160;  // 设置高度使恐龙蹲下时能够躲过
                
                pterosaurs.push_back(new Pterosaur(x, y, birdImages));  // 使用鸟的图片作为替代
            }
            pterosaurSpawnCounter++;
            
            if (pterosaurSpawnCounter >= pterosaurSpawnInterval) {
                pterosaurSpawnCounter = 0;
                std::uniform_int_distribution<int> dist(180, 350);
                pterosaurSpawnInterval = dist(rng);
            }
            
            std::vector<Pterosaur*>::iterator pterosaurIt;
            for (pterosaurIt = pterosaurs.begin(); pterosaurIt != pterosaurs.end();) {
                (*pterosaurIt)->move();
                
                if ((*pterosaurIt)->getX() < -(*pterosaurIt)->getWidth()) {
                    delete *pterosaurIt;
                    pterosaurIt = pterosaurs.erase(pterosaurIt);
                } else {
                    ++pterosaurIt;
                }
            }
        }
        
        // 更新恐龙
        dragon->update();
        
        // 更新分数
        score += 0.1f;
    }
    
    void render() {
        cleardevice();
        
        if (dragon->isHit) {
            // 绘制游戏结束界面
            int gameoverX = screenWidth / 2 - gameoverImage.getwidth() / 2;
            putimage(gameoverX, 120, &gameoverImage);
            
            restartX = screenWidth / 2 - restartImage.getwidth() / 2;
            restartY = 170;
            putimage(restartX, restartY, &restartImage);
            return;
        }
        
        // 绘制背景
        background->draw();
        
        // 绘制云
        for (size_t i = 0; i < clouds.size(); i++) {
            clouds[i]->draw();
        }
        
        // 绘制仙人掌
        for (size_t i = 0; i < items.size(); i++) {
            items[i]->draw();
        }
        
        // 绘制鸟
        for (size_t i = 0; i < birds.size(); i++) {
            birds[i]->draw();
        }
        
        // 绘制翼龙
        for (size_t i = 0; i < pterosaurs.size(); i++) {
            pterosaurs[i]->draw();
        }
        
        // 绘制恐龙
        dragon->draw();
        
        // 绘制分数
        TCHAR scoreText[20];
        _stprintf_s(scoreText, _T("%dm"), static_cast<int>(score));
        settextcolor(RGB(83, 83, 83));
        settextstyle(20, 0, _T("Arial"));
        setbkmode(TRANSPARENT);
        
        int textWidth = textwidth(scoreText);
        outtextxy(screenWidth - textWidth - 10, 10, scoreText);
    }
    
    void detectCollision() {
        if (dragon->isHit) {
            return;
        }
        
        // 碰撞检测时的偏移量，用于调整碰撞检测的精度
        const int offsetX = 20;  // 水平方向上的偏移量
        const int offsetY = 25;  // 垂直方向上的偏移量
        
        // 检测与仙人掌的碰撞 - 使用更精确的碰撞盒
        for (size_t i = 0; i < items.size(); i++) {
            int dragonLeft = dragon->getX() + offsetX;
            int dragonRight = dragon->getX() + dragon->getWidth() - offsetX;
            int dragonTop = dragon->getY() + offsetY;
            int dragonBottom = dragon->getY() + dragon->getHeight() - offsetY;
            
            int cactusLeft = items[i]->getX() + offsetX;
            int cactusRight = items[i]->getX() + items[i]->getWidth() - offsetX;
            int cactusTop = items[i]->getY() + offsetY;
            int cactusBottom = items[i]->getY() + items[i]->getHeight() - offsetY;
            
            if (dragonRight > cactusLeft && dragonLeft < cactusRight &&
                dragonBottom > cactusTop && dragonTop < cactusBottom) {
                dragon->isHit = true;
                break;
            }
        }
        
        // 检测与鸟的碰撞
        for (size_t i = 0; i < birds.size(); i++) {
            int dragonLeft = dragon->getX() + offsetX;
            int dragonRight = dragon->getX() + dragon->getWidth() - offsetX;
            int dragonTop = dragon->getY() + offsetY;
            int dragonBottom = dragon->getY() + dragon->getHeight() - offsetY;
            
            int birdLeft = birds[i]->getX() + offsetX;
            int birdRight = birds[i]->getX() + birds[i]->getWidth() - offsetX;
            int birdTop = birds[i]->getY() + offsetY;
            int birdBottom = birds[i]->getY() + birds[i]->getHeight() - offsetY;
            
            if (dragonRight > birdLeft && dragonLeft < birdRight &&
                dragonBottom > birdTop && dragonTop < birdBottom) {
                dragon->isHit = true;
                break;
            }
        }
        
        // 检测与翼龙的碰撞
        for (size_t i = 0; i < pterosaurs.size(); i++) {
            // 如果恐龙正在蹲下，且翼龙在头顶上方，不算碰撞
            if (dragon->getStyle() == 1) {
                // 翼龙底部低于恐龙头部，才可能碰撞
                // 这里160是翼龙飞行高度，需要根据实际游戏测试调整这个判断条件
                int pterosaurBottom = pterosaurs[i]->getY() + pterosaurs[i]->getHeight();
                int dragonTop = dragon->getY();
                
                if (pterosaurBottom < dragonTop + 10) {
                    // 翼龙飞过头顶，不判断碰撞
                    continue;
                }
            }
            
            int dragonLeft = dragon->getX() + offsetX;
            int dragonRight = dragon->getX() + dragon->getWidth() - offsetX;
            int dragonTop = dragon->getY() + offsetY;
            int dragonBottom = dragon->getY() + dragon->getHeight() - offsetY;
            
            int pterosaurLeft = pterosaurs[i]->getX() + offsetX;
            int pterosaurRight = pterosaurs[i]->getX() + pterosaurs[i]->getWidth() - offsetX;
            int pterosaurTop = pterosaurs[i]->getY() + offsetY;
            int pterosaurBottom = pterosaurs[i]->getY() + pterosaurs[i]->getHeight() - offsetY;
            
            if (dragonRight > pterosaurLeft && dragonLeft < pterosaurRight &&
                dragonBottom > pterosaurTop && dragonTop < pterosaurBottom) {
                dragon->isHit = true;
                break;
            }
        }
        
        // 如果发生碰撞，播放游戏结束音效，降低音量
        if (dragon->isHit) {
            PlaySound(_T("sounds/dragon/gameover.wav"), NULL, SND_ASYNC | SND_NODEFAULT);
        }
    }
};

int main() {
    Game game;
    game.run();
    return 0;
} 